<?php
class TView extends Exception
{
	private $controller;
	private $temp;

	public static function getI(TController $c){
		$i =  new TView();
		$i->setController($c);
		return $i;
	}
	public function setController($c){
		$this->controller = $c;
	}
	public function getController(){
		return $this->controller;
	}

	public function setTemplate($temp){
		$this->temp = $temp;
	}

	public function isTemplate(){
		return isset($this->temp);
	}

	public function show(){
		if(USE_TEMPLATES == true){
			if(!$this->isTemplate()){
				throw new EView();
			}
			if(!is_readable(TEMPLATES_DIR.'/'.$this->temp.EXTENSION_NAME)){
				throw new EView();
			}
			require_once(TEMPLATES_DIR.'/'.$this->temp.EXTENSION_NAME);
		}
	}
}
class EView extends TView
{
	public static function getI($msg = '', $cd = 0){
		return new EView($msg, $cd);
	}
}
